//
//  TopImageTwoBottomLabelCell.m
//  eidaily
//
//  Created by 邬思萍 on 2019/8/9.
//  Copyright © 2019 fybdp. All rights reserved.
//

#import "TopImageTwoBottomLabelCell.h"
#import "Masonry.h"

@interface TopImageTwoBottomLabelCell()

@property (nonatomic,strong) UIImageView *topImageView;
@property (nonatomic,strong) UILabel *firstLabel;
@property (nonatomic,strong) UILabel *secondLabel;
@property (nonatomic,strong) UILabel *markLabel;
@end

@implementation TopImageTwoBottomLabelCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self UIConfig];
    }
    return self;
}

- (void)UIConfig{
    [self addSubview:self.topImageView];
    [self addSubview:self.firstLabel];
    _firstLabel.text = FYLocalizedString(@"oxygen_name", @"");
    
    [_topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self);
        make.top.mas_equalTo(0);
        make.width.mas_equalTo(self);
        make.height.mas_equalTo(124);
    }];
    
//    [_topImageView jk_cornerRadius:kImageViewRadius strokeSize:0 color:nil];

    
    [_firstLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topImageView.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
        make.left.width.mas_equalTo(self);
        make.bottom.mas_equalTo(self);

    }];
}

/*
 上圆角
 */
- (void)addTopRadiusWithView:(UIView *)view{
    view.layer.cornerRadius = 0;
    //左上角和右上角圆角
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(2, 2)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
}

- (void)setDeviceType:(ARTDeviceType)deviceType{
    _deviceType = deviceType;
    if (deviceType == ARTDeviceTypeOximeter) {
        _topImageView.image = [UIImage imageNamed:@"search_ic_xueyang"];
        _firstLabel.text = FYLocalizedString(@"oxygen_name", @"");
    }else if (deviceType == ARTDeviceTypeFetalHeart){
        _topImageView.image = [UIImage imageNamed:@"search_ic_fetal"];
        _firstLabel.text = FYLocalizedString(@"fhr_name", @"");
    }else if (deviceType == ARTDeviceTypeWatch){
        _topImageView.image = [UIImage imageNamed:@"search_ic_watch"];
        _firstLabel.text = FYLocalizedString(@"sleep_watch_name", @"");
    }else if (deviceType == ARTDeviceTypePlateau){
        _topImageView.image = [UIImage imageNamed:@"search_ic_poximeter"];
        _firstLabel.text = FYLocalizedString(@"Highland Pulse Oximeter", @"");
    }else if (deviceType == ARTDeviceTypePelvicMuscles){
        _topImageView.image = [UIImage imageNamed:@"search_icon_pelvic"];
        _firstLabel.text = FYLocalizedString(@"pelvic_floor_name", @"");
    }
    [_firstLabel setAdjustsFontSizeToFitWidth:YES];
}

#pragma mark--GETTER
- (UIImageView *)topImageView{
    if (!_topImageView){
        _topImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _topImageView.image = [UIImage imageNamed:@"search_ic_xueyang"];
    }
    return _topImageView;
}

- (UILabel *)firstLabel{
    if (!_firstLabel){
        _firstLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _firstLabel.font = [UIFont systemFontOfSize:17];
        _firstLabel.textAlignment = NSTextAlignmentCenter;
        _firstLabel.textColor = J_ColorFromHEX(0x0095B6);
        _firstLabel.adjustsFontSizeToFitWidth = YES;
        _firstLabel.numberOfLines = 2;
    }
    return _firstLabel;
}

- (UILabel *)secondLabel{
    if (!_secondLabel) {
        _secondLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _secondLabel.font = [UIFont systemFontOfSize:12];
//        _secondLabel.textColor = [UIColor color_a8a8a8];
    }
    return _secondLabel;
}

- (UILabel *)markLabel{
    if (!_markLabel) {
        _markLabel = [[UILabel alloc] init];
        _markLabel.textAlignment = NSTextAlignmentCenter;
//        [_markLabel setBackgroundColor:[UIColor primaryColor]];
        _markLabel.text = @"首发";
        _markLabel.font = [UIFont systemFontOfSize:11];
        _markLabel.textColor = [UIColor whiteColor];
    }
    return _markLabel;
}

@end
